package com.xmy.cultivate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.SenateScoreSet;
import com.xmy.cultivate.mapper.SenateScoreSetMapper;
import com.xmy.cultivate.service.ISenateScoreSetService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 教务获取积分设置 服务实现类
 * </p>
 *
 * @author hpiggy
 * @since 2024-10-26
 */
@Service
public class SenateScoreSetServiceImpl extends ServiceImpl<SenateScoreSetMapper, SenateScoreSet> implements ISenateScoreSetService {


    @Override
    public SenateScoreSet getSenateScoreSetOne(Integer yearPart, Integer quarterNum, Integer yearClassId,Long subjectsId, Long projectsId) {
        QueryWrapper<SenateScoreSet> senateScoreSetQueryWrapper = new QueryWrapper<>();
        senateScoreSetQueryWrapper.eq("year_part", yearPart);
        senateScoreSetQueryWrapper.eq("quarter_num", quarterNum);
        senateScoreSetQueryWrapper.eq("subjects_id", subjectsId);
        senateScoreSetQueryWrapper.eq("senate_project_id", projectsId);
        //Integer gradeSection = CommonUtil.getGradeSection(yearClassId);
        //senateScoreSetQueryWrapper.and(i -> i.eq("year_class_id", yearClassId).or().eq("grade_section", gradeSection));//暂时不按年级
        senateScoreSetQueryWrapper.last("limit 1");
        return this.getOne(senateScoreSetQueryWrapper);
    }
}
